%writetable(TableObj,'test.xlsx','FileType','spreadsheet','Sheet','MyTable')

global par_;

%Change directory
relative_path = '../../results/matlab/';
%switch par_.model
%    case {4,5,6,7}
        directory_name = ['Model' num2str(par_.model) 'Moment' par_.mymoment 'Distribution' par_.switch_distribution];
%    case {2,3}
%        directory_name = ['Model' num2str(4) 'Moment' par_.mymoment 'Distribution' par_.switch_distribution];
%end
eval(['directory_exist = isfolder(''' relative_path directory_name ''');']);
if ~directory_exist
 eval(['mkdir ''' relative_path directory_name ''';']);
end

%Do it if doss=1
if par_.doss
 
%What is the country?
  filename = 'moments.xlsx';
 
  mymoments_cell = {'gap_data','gap_density_model','density_data'};
 T=table(deviation_data*100,gap_density_model*100,density_data*100,'VariableNames',mymoments_cell);
 mymoments_name = 'gap_density';
 write_table;

 mymoments_cell = {'gap_data','lambda_prime_model','hazard_data'};
 T=table(deviation_data*100,lambda_prime_model*100,freq_data*100,'VariableNames',mymoments_cell);
 mymoments_name = 'generalized hazard';
 write_table;
 
 mymoments_cell = {'std_ref_price_data','stand_pc_dist_model','std_ref_price_density_data'};
 T=table(std_ref_price_data,stand_pc_dist_model*100,std_ref_price_density_data*100,'VariableNames',mymoments_cell);
 mymoments_name = 'std_pc_density';
 write_table;

 mymoments_cell = {'std_gap_data','std_gap_density_model','std_gap_density_data'};
 T=table(std_gap_data,std_gap_density_model*100,std_gap_density_data*100,'VariableNames',mymoments_cell);
 mymoments_name = 'std density';
 write_table;

 mymoments_cell = {'gap_data','lambda','lambda_h1','lambda_h3','lambda_h12','lambda_h24'};
 T=table(deviation_data*100,lambda_model*100,lambda_prime_h1_model*100,lambda_prime_h3_model*100,lambda_prime_h12_model*100,lambda_prime_h24_model*100,'VariableNames',mymoments_cell);
 mymoments_name = 'lambdaprime';
 write_table;

 elseif par_.dodyn==1
  filename = 'irf.xlsx';
 
 mymoments_cell = {'Money_growth','Inflation','Output','Real_wage','Price_level','Nominal_wage','Nominal_money'};
 T=table(scalefactor*d_R_path',scalefactor*(d_PI_path'),scalefactor*(d_C_path'/Cbar),scalefactor*(w_path'/wbar-1),...
     scalefactor*(cumsum(PI_path'-mu)),scalefactor*((w_path'/wbar-1)+cumsum(PI_path'-mu)),scalefactor*(cumsum(mu_path'-mu)),'VariableNames',mymoments_cell);
 switch par_.model
     case 4
        mymoments_name = 'Woodford';
     case 2
        mymoments_name = 'Calvo';
     case 3
        mymoments_name = 'GL';
     case 6
        mymoments_name = 'AsymHazard';
 end
 write_table;

end